let genertor = require('chinese-address-generator')
const generator4 = require('chinese-address-generator/generator4');
const fs = require('fs')

let generateLevel1List = []
let generateLevel2List = []
let generateLevel3List = []
let generateLevel4List = []
let fabricateFullAddressList = []

for (let i = 0; i < 20; i++) {
  // 生成完整的地址
  generateLevel1List.push(genertor.generateLevel1())
  generateLevel2List.push(genertor.generateLevel2())
  generateLevel3List.push(genertor.generateLevel3())
  generateLevel4List.push(generator4.generateLevel4())

  fabricateFullAddressList.push(generator4.fabricateFullAddress())
}

let writeText = (filename, data) => {
  fs.writeFile(filename, JSON.stringify(data, null, 2), (err, data) => {
    if (err) {
      console.log(err)
      return
    }
    console.log('文件写入完成')
  })
}


writeText('generateLevel1List.json', generateLevel1List)
writeText('generateLevel2List.json', generateLevel2List)
writeText('generateLevel3List.json', generateLevel3List)
writeText('generateLevel4List.json', generateLevel4List)
writeText('fabricateFullAddressList.json', fabricateFullAddressList)